import { TagList } from '@/api/dataProvider'
import { fetchCategories } from '@/api/cms'
const cms = {
  state: {
      tags: [],
      category: [],
  },
  mutations: {
      SET_TAG: (state, tags) => {
          state.tags = tags
      },
      SET_CATEGORY: (state, category) => {
          state.category = category
      },
  },
  actions: {
      fetchTags ({commit}) {
          TagList().then((res) => {
              // console.log(res)
              commit('SET_TAG', res.data.data)
          })
      },
      fetchCategoryList ({commit, state}) {
          fetchCategories().then((res) => {
              // console.log(res)
              commit('SET_CATEGORY', res.data)
          })
      },
  }
}

export default cms
